package com.example.anew.journey.mynewjourney.logic.resetPassword;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.anew.journey.mynewjourney.R;
import com.example.anew.journey.mynewjourney.base.BaseRegisteredAndLoginActivity;
import com.example.anew.journey.mynewjourney.logic.resetPassword.bean.ResetPhoneAndNumber;
import com.example.anew.journey.mynewjourney.logic.resetPassword.perstenter.ResetPasswordPersenter;
import com.example.anew.journey.mynewjourney.logic.resetPassword.view.ISResetPasswordView;

import org.greenrobot.eventbus.EventBus;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 杭州惟君医疗科技有限公司16
 * Created by 20433 on 2018/3/5
 */

public class ResetPasswordActivity extends BaseRegisteredAndLoginActivity implements ISResetPasswordView {
    @Bind(R.id.activity_reset_password_tv_password_pager_introduce)
    TextView activityResetPasswordTvPasswordPagerIntroduce;
    @Bind(R.id.activity_reset_password_tv_version_code_send_phone)
    TextView activityResetPasswordTvVersionCodeSendPhone;
    @Bind(R.id.activity_reset_password_et_input_version_code)
    EditText activityResetPasswordEtInputVersionCode;
    @Bind(R.id.activity_reset_password_et_input_new_password)
    EditText activityResetPasswordEtInputNewPassword;
    @Bind(R.id.linearLayout4)
    LinearLayout linearLayout4;
    @Bind(R.id.activity_reset_password_bt_login)
    Button activityResetPasswordBtLogin;
    private String phone;

    private ResetPasswordPersenter mResetPasswordPersenter = new ResetPasswordPersenter(this);


    /**
     * @desc 初始化数据 onCreate()
     */
    @Override
    protected void initView(View view) {
        // todo Toolbar的一系列操作
        setToolbarBg(0xffffffff);
        //findResetPassword(view);
        phone = getIntent().getStringExtra("phone");
        mResetPasswordPersenter.setPhoneNumber("验证码已发送至"+phone);

    }
    /**
     * @desc 主要内容的布局资源填充进来
     */
    @Override
    protected View setMainContentView() {
        View view = View.inflate(this, R.layout.activity_reset_password, null);
        ButterKnife.bind(this,view);
        activityResetPasswordBtLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mResetPasswordPersenter.onClickLogin();
            }
        });
        return view;
    }
    /**
     * @desc Activity 销毁 释放资源
     */
    @Override
    protected void releaseResources() {
        ButterKnife.unbind(this);
    }

    // 给出提示
    @Override
    public void showToastInformation(String str) {
        Toast.makeText(this,str,Toast.LENGTH_SHORT).show();
    }
    // 获取验证码
    @Override
    public String getInputVersionCode() {
        return activityResetPasswordEtInputVersionCode.getText().toString().trim();
    }
    // 获取新密码
    @Override
    public String getNewPassword() {
        return activityResetPasswordEtInputNewPassword.getText().toString();
    }
    // 设置手机号
    @Override
    public void setPhoneNumber(String str) {
        activityResetPasswordTvVersionCodeSendPhone.setText(str);
    }
    //获取手机号
    @Override
    public String getPhoneNumber() {
        return phone;
    }
    //跳转到主页
    @Override
    public void toFirstChangeMainActivity() {
//        Intent intent = new Intent(ResetPasswordActivity.this, LoginActivity.class);
//        startActivity(intent);
        finish();
    }
    //回到上个页面
    @Override
    public void toBackLastPage() {
        finish();
    }
    //手机号和密码发送到登陆页面
    @Override
    public void SendMessage(String phoneNumber,String password) {
        EventBus.getDefault().post(new ResetPhoneAndNumber(phoneNumber,password));
    }
}
